package org.andcool.animation.ease;

/**
 * @author Joosun
 * @since 2011-5-8
 */
public class EaseExponential extends BaseEase
{
	public EaseExponential(final EasingMode pEasingMode)
	{
		super(pEasingMode);
	}

	@Override
	protected float getEaseInInterpolation(final float pPercentage)
	{
		return (float) ((pPercentage == 0) ? 0 : Math.pow(2, 10 * (pPercentage - 1)));
	}

	@Override
	protected float getEaseOutInterpolation(final float pPercentage)
	{
		return (float) ((pPercentage >= 1) ? 1 : (-Math.pow(2, -10 * pPercentage) + 1));
	}

	@Override
	protected float getEaseInOutInterpolation(float pPercentage)
	{
		if (pPercentage == 0)
		{
			return 0;
		}
		if (pPercentage >= 1)
		{
			return 1;
		}

		pPercentage *= 2;

		if (pPercentage < 1)
		{
			return (float) (0.5f * Math.pow(2, 10 * (pPercentage - 1)));
		}
		else
		{
			return (float) (0.5f * (-Math.pow(2, -10 * --pPercentage) + 2));
		}
	}
}